// eslint-disable-next-line import/no-extraneous-dependencies
const path = require('path')

const configureWebpack = {
  module: {
    rules: [
      { test: /\.wasm$/, type: 'javascript/auto', use: 'file-loader' }
    ]
  },
  resolve: {
    extensions: ['.js', '.json', '.vue']
  },
  devtool: 'souce-map'
}

module.exports = {
  configureWebpack,
  chainWebpack (config) {
    config
      .plugin('html')
      .tap((args) => {
        args[0].title = 'todolist'
        return args
      })

    config.module
      .rule('html')
      .test(/\.html$/)
      .use('html-loader')
      .loader('html-loader')
      .end()

    config.module
      .rule('html')
      .exclude
      .add(/public\/index+/)
      .end()

    config.module.rule('less').oneOf('vue').use('style-resource')
      .loader('style-resources-loader')
      .options({
        patterns: [
          path.resolve(__dirname, './src/styles/variable.less')
        ]
      })
  },

  devServer: {
    disableHostCheck: true,
    historyApiFallback: true
  }
}
